<?php
/**
 * VoteAddWidget
 * 添加投票Widget，可以放在任意位置
 * @uses Widget
 * @package
 * @version $id$
 * @copyright 2001-2013 SamPeng
 * @author SamPeng <penglingjun@zhishisoft.com>
 * @license PHP Version 5.2 {@link www.sampeng.org}
 */
class editNewsWidget extends Widget
{
	//static $rand = 0;
	public function render($data)
	{
		//self::$rand ++;
		//$data['rand'] = self::$rand;
		//$data['time'] = getdate();
		//$data['count'] = 2;
		//$data['exit'] = isset($data['exit'])?$data['exit']:true;
		$model = D('News');
		
		$get_info = $model->where(array('news_id'=>$_GET['id'],'state'=>-1))->find();//只允许编辑待审核的
		
		if(empty($get_info)){
			return $this->error('获取数据失败');
		}
		$data['info'] = $get_info;
		//$this->assign('info',$get_info);
		$type_ids = array('0' => '--无--') ;
    	$cate = model('CategoryTree');
    	$pc = $cate->settable('news_category')->getCategoryList(0) ;
    	foreach ($pc as $pv)
    	{
    		//查找子分类
    		$pid = $pv['news_category_id'];
    		$type_ids[$pid] = $pv['title']; 
    		$child = $cate->getCategoryList($pid) ;
    		foreach ($child as $cv)
    		{
    			$type_ids[$cv['news_category_id']] ='&nbsp;&nbsp;&nbsp;--- '. $cv['title'];
    		}
    		
    	}
		$data['type_ids'] = $type_ids;
		$content = $this->renderFile(dirname(__FILE__) . '/editNews.html',$data);
    	
		return $content;
	}
}
